//
//  HZL_BaseViewController.m
//  B_Project
//
//  Created by 胡佳俊 on 15/11/23.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_BaseViewController.h"

@interface HZL_BaseViewController ()

@end

@implementation HZL_BaseViewController
- (void)viewWillAppear:(BOOL)animated
{
    self.view.backgroundColor = [UIColor whiteColor];
    
//    self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil];
    [self.navigationController.navigationBar setTitleTextAttributes:attributes];
    
    self.tabBarController.tabBar.tintColor = [UIColor colorWithRed:0.01 green:0.73 blue:0.61 alpha:1];
//    self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
    self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
    self.tabBarController.tabBar.alpha = 0.9;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
//    self.alertBtn= [UIButton buttonWithType:UIButtonTypeCustom];
//    self.alertBtn.backgroundColor = [UIColor lightGrayColor];
//    [self.alertBtn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
//    [self.alertBtn setTitle:@"点击重新加载" forState:UIControlStateNormal];
//    self.alertBtn.frame = self.view.bounds;
//    [self.view addSubview:self.alertBtn];
    
    
    
    
    // 注册通知
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(changeCity:) name:@"changeCity" object:nil];
    
}


- (void)changeCity:(NSNotification *)note
{
//    self.navigationItem.leftBarButtonItem.title = note.object;
}
- (void)buttonClick {
    
}
#pragma mark - 加载
- (void)loadMBProgress
{
    self.hud = [[MBProgressHUD alloc] initWithView:self.view];
    
    self.hud.dimBackground = NO;
    //设置对话框文字
    self.hud.labelText = @"loading";
    self.hud.minShowTime = 50;
    self.hud.activityIndicatorColor = [UIColor whiteColor];
    self.hud.labelColor = [UIColor whiteColor];
    
    [self.view addSubview:self.hud];
    [self.hud showAnimated:YES whileExecutingBlock:^{
        //对话框显示时需要执行的操作
        sleep(1);
    } completionBlock:^{
        //操作执行完后取消对话框
        [self.hud removeFromSuperview];
        self.hud = nil;
    }];
}
//计算文本高度的方法
+ (CGFloat)heightWithText:(NSString *)text fontSize:(CGFloat)fontsize Width:(CGFloat)width

{
    //设置一个字典 保存文本属性
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:fontsize]};
    
    //预设尺寸 文本最大不会超过这个范围
    CGSize size = CGSizeMake(width, 2000);
    //根据文本信息 计算得到一个CGRect
    //参数1. 尺寸范围
    //参数2. 获取文本尺寸的方式
    //参数3. 文本属性
    //参数4. 无用信息(上下文)
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
